/***
 * 资源申请list
 */
var ResApplyList = new Pearlsen.BaseList({
	gridId:'resApplyGrid',
	advSearchId:'advSearchWin1',
	module:'资源申请',
	modulePath:'/pages/rms/resapply/',
	moduleName:'ResApply',
	idProperty:'applyId',
	nameProperty:'resName',
	dataSetHandler:'ResApplyDataSetHandler',
	queryHandler:'ResApplyQueryHandler',
	renderStepStatus:function(value){
		var color=['green','orange','green','orange','green','red','orange','orange'];
		var arr=['新建','待审批','未处理','已处理','已完成,审批通过','已完成,审批拒绝','审批通过,待执行','审批通过,已执行'];
		try{
			var intIndex = parseInt(value);
			return '<span style=\'color:'+color[intIndex]+';\'>'+arr[intIndex]+'</span>';
		}catch(e){
		}
        return "";
	},
	gridViewConfig:function(record,rowIndex,rowParams,store){
		var ret="";
		var stepStatus=record.data.stepstatus;
		switch(stepStatus){
			case '0':
				ret='x-grid-record-red';
				break;
			case '1':
				ret='x-grid-record-red';
				break;
			case '2':
				ret='x-grid-record-red';
				break;
			case '3':
				ret='x-grid-record-red';
				break;
			case '4':
				ret='x-grid-record-red';
				break;		
			case '5':
				ret='x-grid-record-red';
				break;		
		}
		return ret;
	},
	edit:function(){
		var record = this.getSelectedOne();
		if( record ) {
			var stepstatus = record.data['stepstatus'];
			if( parseInt(stepstatus) > 0 ){
    			Pearlsen.Utils.showInfoMsg("该申请已经提交,不能编辑");
			}else{
				var tabId = this.createTabId("edit",record.data[this.idProperty]);
				parent.MainTab.addTab(tabId,"编辑"+this.module,this.getEditUrl());
			}
		}else{
			Pearlsen.Utils.showInfoMsg('请先选中一条记录');
		}
	},
	del:function(){
		var records = this.getSelected();
     	if( Ext.isEmpty(records)){
     		Pearlsen.Utils.showInfoMsg('请先选中一条记录.');
     		return ;
     	}
     	for( var i = 0 ; i < records.length; i++ ){
     		var record = records[i];
			var stepstatus = record.data['stepstatus'];
			if( parseInt(stepstatus) > 0 ){
				Pearlsen.Utils.showInfoMsg("已经提交申请的任务,不能删除");
				return ;
			}
     	}

     	if(records.length ==1 ){
     		this._delOne();
     	}else{
     		this._delAll();
     	}
	}
	
});
